﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Net.Sockets;
using Common;

namespace helper
{
    public class TcpHelper
    {
        /// <summary>
        /// 将数据转发到指定的连接，一般用于不期望响应的操作，比如某角色说话的信息
        /// </summary>
        /// <param name="datas"></param>
        /// <param name="length"></param>
        /// <param name="client"></param>
        /// <returns>返回是否转发成功</returns>
        public static bool Forward(TcpClient client, byte[] datas, int length)
        {
            try
            {
                client.GetStream().Write(datas, 0, length);
            }
            catch (Exception ex)
            {
                //调试信息记录
                Tools.PrintException(ex);
                return false;
            }
            return true;
        }
    }
}
